varying vec3 normal,lightDir,halfVector,viewerVec;
uniform vec3 lpos[2];
	
void main()
{
	vec4 I[2], Ia, Id, Is;
	vec3 n, lv, rv, vv;
	float NdotL, RdotV, power;

	n  = normalize( normal );
	vv = normalize( viewerVec );	

for( int i = 0; i < 2; i++ ){

	lv = normalize( lpos[i] );

	rv = normalize( 2.0 * dot( n, lv ) * n - lv );	

	NdotL = dot( n, lv );
	RdotV = dot( rv, vv );
	power = pow( RdotV, gl_FrontMaterial.shininess );

	Ia = gl_LightSource[0].ambient * gl_FrontMaterial.ambient;
	Id = gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse * max( NdotL, 0.0 ) ;
	Is = gl_LightSource[0].specular * gl_FrontMaterial.specular * power;

	I[i] = Ia + Id + Is;
}

I[0].r = I[0].r / 2.0;
I[0].g = I[0].g / 2.0;
I[0].b = I[0].b / 2.0;

I[1].r = I[1].r / 2.0;
I[1].g = I[1].g / 2.0;
I[1].b = I[1].b / 2.0;	

	gl_FragColor = I[0] + I[1];
}